/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package com.linktco.prison.impl;

import com.linktco.common.utils.DateUtils;
import com.linktco.common.utils.IdCardUtil;
import com.linktco.prison.entity.CabinetUser;
import com.linktco.prison.vo.CabinetUserVO;
import com.linktco.prison.mapper.CabinetUserMapper;
import com.linktco.prison.service.ICabinetUserService;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;

import javax.annotation.PostConstruct;
import java.time.LocalDate;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * 档案人员信息表 服务实现类
 *
 * @author BladeX
 * @since 2024-12-23
 */
@Service
public class CabinetUserServiceImpl extends BaseServiceImpl<CabinetUserMapper, CabinetUser> implements ICabinetUserService {

	@Override
	public IPage<CabinetUserVO> selectCabinetUserPage(IPage<CabinetUserVO> page, CabinetUserVO cabinetUser) {
		return page.setRecords(baseMapper.selectCabinetUserPage(page, cabinetUser));
	}

	@Override
	public IPage<CabinetUserVO> excludePage(IPage<CabinetUserVO> page, CabinetUserVO cabinetUser) {
		return page.setRecords(baseMapper.excludePage(page, cabinetUser));
	}





	private void generateUser(){
		List<CabinetUser> userList = new ArrayList<>();
		for (int i = 0; i <3000 ; i++) {
			String name = IdCardUtil.getName();
			String idCard = IdCardUtil.getIdCard("522320");
			CabinetUser user = new CabinetUser();
			user.setCrimeName("抢劫");
			user.setName(name);
			user.setIdCard(idCard);
			user.setEnterDate(DateUtils.randomDate(1950,70));
			user.setUserNo(idCard.substring(idCard.length()-6));
			userList.add(user);
		}
		saveBatch(userList);

	}


}
